from time import sleep

from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By

from python.pageDecorator import Page


@Page
class LoginPage:
    u_loc = (By.ID, "u")
    p_loc = (By.ID, "p")

    def __init__(self, driver,*args, **kwargs):
        # self.driver = driver
        self.driver = Chrome()
        import os
        testpage=os.path.join(os.path.dirname(os.path.abspath(__file__)),"testpage.html")
        self.driver.get("file:///"+testpage)

    def login(self, u, p):
        # 关键
        self.u.send_keys(u)
        self.p.send_keys(p)


if __name__ == '__main__':
    a = LoginPage(None)
    a.login("test", "123456")
    a.driver.close()
    sleep(3)
    a.xixi()  # test raise AttributeError
